﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

using Sound;

namespace Darwin.Source.Components.World.Entities
{
    enum eEntityState
    {
        _IDLE,
        _DEAD,
        _MOVING,
        _ATTACKING
    }

    abstract class CEntity
    {
        protected int m_iHealth;
        protected int m_iDamage;
        protected float m_fMovementSpeed;
        protected Vector3 m_v3Position;
        protected eEntityState m_esEntityState;
        protected Team.CTeam m_myTeam;

        public UInt32 m_UID;

        public Team.Side teamSide;

        public CEntity()
        {
            m_esEntityState = eEntityState._IDLE;
            m_iHealth = 100;
            m_iDamage = 0;
            m_fMovementSpeed = 1.0f;
            m_v3Position = new Vector3(0,0,0);
            m_UID = ++Components.World.World.m_UniversalID;
        }

        public virtual bool Initialise(Team.CTeam myTeam)
        {
            m_myTeam = myTeam;
            return true;
        }

        public abstract void DoRender();
        public abstract void DoUpdate( GameTime gameTime, World w, List<PotentialFeild.CPotentialFeildVector> potentialFeildVectors, Vector4[] worldFeildData );

        public int Health
        {
            get { return m_iHealth; }
            set 
            { 
                m_iHealth = value;
                if (m_iHealth <= 0) // Kill the unit
                {
                    SoundManager.getSoundManager().playSound(2);
                    m_esEntityState = eEntityState._DEAD;
                }
            }
        }

        public eEntityState EntityState
        {
            get { return m_esEntityState; }
            set { m_esEntityState = value; }
        }

        public Vector3 Position
        {
            get { return m_v3Position; }
            set { m_v3Position = value; }
        }
    }
}
